import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.sql.SQLOutput;

/**
 * 数制转换
 */
public class chap3_1 {
    public static void conversion(int N,int r){
        sequenceStack<Integer> s=new sequenceStack<Integer>();
        /*定义一个顺序栈*/
        while(N!=0){
            s.push(N%r);
            N=N/r;
        }
        System.out.println("转换结果为：");
        while (!s.isEmpty()){
            System.out.println(s.pop());
        }
    }

    public static void main(String[] args) {
        BufferedReader br;
        Integer num,radix;
        try {
            br=new BufferedReader(new InputStreamReader(System.in));
            System.out.println("输入一个十进制整数：");
            num=Integer.parseInt(br.readLine());
            System.out.println("转换进制：");
            radix=Integer.parseInt(br.readLine());
            conversion(num,radix);
        }catch (IOException e){
            e.printStackTrace();
        }
    }
}
